<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>简单实用国产jQuery UI框架 - DWZ富客户端框架(J-UI.com)</title>

<link href="http://j-ui.com/themes/default/style.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="http://j-ui.com/themes/css/core.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="http://j-ui.com/themes/css/print.css" rel="stylesheet" type="text/css" media="print"/>
<link href="http://j-ui.com/uploadify/css/uploadify.css" rel="stylesheet" type="text/css" media="screen"/>
<!--[if IE]>
<link href="http://j-ui.com/themes/css/ieHack.css" rel="stylesheet" type="text/css" media="screen"/>
<![endif]-->

<!--[if lte IE 9]>
<script src="http://j-ui.com/js/speedup.js" type="text/javascript"></script>
<![endif]-->

<script src="http://j-ui.com/js/jquery-1.7.2.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/jquery.cookie.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/jquery.validate.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/jquery.bgiframe.js" type="text/javascript"></script>
<script src="http://j-ui.com/uploadify/scripts/jquery.uploadify.js" type="text/javascript"></script>

<!-- svg图表  supports Firefox 3.0+, Safari 3.0+, Chrome 5.0+, Opera 9.5+ and Internet Explorer 6.0+ -->
<script type="text/javascript" src="http://j-ui.com/chart/raphael.js"></script>
<script type="text/javascript" src="http://j-ui.com/chart/g.raphael.js"></script>
<script type="text/javascript" src="http://j-ui.com/chart/g.bar.js"></script>
<script type="text/javascript" src="http://j-ui.com/chart/g.line.js"></script>
<script type="text/javascript" src="http://j-ui.com/chart/g.pie.js"></script>
<script type="text/javascript" src="http://j-ui.com/chart/g.dot.js"></script>

<script src="http://j-ui.com/js/dwz.core.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.util.date.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.validate.method.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.regional.zh.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.barDrag.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.drag.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.tree.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.accordion.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.ui.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.theme.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.switchEnv.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.alertMsg.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.contextmenu.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.navTab.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.tab.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.resize.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.dialog.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.dialogDrag.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.sortDrag.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.cssTable.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.stable.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.taskBar.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.ajax.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.pagination.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.database.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.datepicker.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.effects.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.panel.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.checkbox.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.history.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.combox.js" type="text/javascript"></script>
<script src="http://j-ui.com/js/dwz.print.js" type="text/javascript"></script>

<script src="http://j-ui.com/js/dwz.regional.zh.js" type="text/javascript"></script>

<script type="text/javascript">
$(function(){
	DWZ.init("<{$root}>dwz.frag.xml", {
		loginUrl:"login_dialog.html", loginTitle:"登录",	// 弹出登录对话框
//		loginUrl:"login.html",	// 跳到登录页面
		statusCode:{ok:200, error:300, timeout:301}, //【可选】
		pageInfo:{pageNum:"pageNum", numPerPage:"numPerPage", orderField:"orderField", orderDirection:"orderDirection"}, //【可选】
		debug:true,	// 调试模式 【true|false】
		callback:function(){
			initEnv();
			$("#themeList").theme({themeBase:"themes"}); // themeBase 相对于index页面的主题base路径
		}
	});
});

</script>
</head>

<body scroll="no">
	<div id="layout">
		<div id="header">
			<div class="headerNav">
				<a class="logo" href="http://j-ui.com">标志</a>
				<a style="color:white;text-decoration: none;padding-top: 8px;display: block;">支持vim命令&nbsp使用:w保存文件</a>
				<ul class="nav">
					<li><a href="<{:U("manage/zip")}>">zip备份</a></li>
					<li><a onclick="change_theme()" id="editor_theme_link" style="cursor:pointer;">夜间模式</a></li>
					<script>
					var editor_theme=window.localStorage.getItem('editor_theme');
					if (editor_theme=='default') {
						$("#editor_theme_link").html("夜间模式");
						// window.localStorage.setItem('editor_theme','night');
					} else if (editor_theme=='night') {
						$("#editor_theme_link").html("白日模式");
						// window.localStorage.setItem('editor_theme','default');
					};
					change_theme=function(){
						var editor_theme=window.localStorage.getItem('editor_theme');
						if (editor_theme=='default') {
							$("#editor_theme_link").html("白日模式");
							window.localStorage.setItem('editor_theme','night');
						} else if (editor_theme=='night') {
							$("#editor_theme_link").html("夜间模式");
							window.localStorage.setItem('editor_theme','default');
						};
						
					}
					</script>
					<li><a href="#">用户</a></li>
					<li><a href="login.html">退出</a></li>
				</ul>
			</div>

			<!-- navMenu -->
			
		</div>

		<div id="leftside">
			<div id="sidebar_s">
				<div class="collapse">
					<div class="toggleCollapse"><div></div></div>
				</div>
			</div>
			<div id="sidebar">
				<div class="toggleCollapse"><h2>主菜单</h2><div>收缩</div></div>

				<div class="accordion" fillSpace="sidebar">
					
					<div class="accordionContent">
						<!-- <ul class="tree treeFolder">
							<li><a href="<{$root}>dwz.frag.xml" target="navTab" external="true">dwfz.frag.xml</a></li>
						</ul> -->

						<!-- 这儿是目录区 -->
						
					</div>
				</div>
			</div>
		</div>
		<div id="container">
			<div id="navTab" class="tabsPage">
				<div class="tabsPageHeader">
					<div class="tabsPageHeaderContent"><!-- 显示左右控制时添加 class="tabsPageHeaderMargin" -->
						<ul class="navTab-tab">
							<li tabid="main" class="main">
								<a href="javascript:;">
									<!-- 默认页 -->
								</a>
							</li>
						</ul>
					</div>
					<div class="tabsLeft">left</div><!-- 禁用只需要添加一个样式 class="tabsLeft tabsLeftDisabled" -->
					<div class="tabsRight">right</div><!-- 禁用只需要添加一个样式 class="tabsRight tabsRightDisabled" -->
					<div class="tabsMore">more</div>
				</div>
				
				<div class="navTab-panel tabsPageContent layoutBox">
					<div class="page unitBox">
						<!-- 页面框架 -->
					</div>
				</div>
			</div>
		</div>

	</div>

	<div id="footer">Copyright &copy; 2013 <a href="#" target="dialog">李俊@计科1101</a> QQ：706639632</div>
</body>
</html>
<script>
	function write_root (item) {
		$(item).append('<ul class="tree treeFolder collapse" ></ul>');
		return $(item).children("ul");
	}
	function write_dir(item,dir_name,dirpath){
		if(0==arguments.length){
			throw "2 args needed";
		}else if (1==arguments.length) {
			dir_name="未知文件夹";
		}
		var li=document.createElement("li");
		var a=document.createElement("a");
		a.innerHTML=dir_name;
		$(a).attr({'rel': dirpath});
		var ul=document.createElement("ul");
		li.appendChild(a);
		li.appendChild(ul);
		item[0].appendChild(li);
		return $(ul);
	}
	function write_file(item,file_name,url) {
		if(0==arguments.length){
			throw Error("3 args needed");
		}else if (1==arguments.length) {
			dir_name="未知文件";
			url="";
		}else if (2==arguments.length) {
			url="";
		}
		$(item).append('<li><a href="'+url+'" target="navTab" rel="'+url+'" external="true">'+file_name+'</a></li>');
		return $(item).children("li");
	}

	function tree_construct(base,json,parent) {
		for (var e in json) {
			if (!isNaN(e)) {
				var filepath=parent+"/"+json[e];
				write_file(base,json[e],filepath);
			} else{
				var dirpath=parent+"/"+e+"/";
				var son_dir=write_dir(base,e,dirpath);
				tree_construct(son_dir,json[e],parent+"/"+e);
			};
		};
	}

	$(document).ready(function() {
		var json_dir = $.ajax({
		  url: "<{:U("filetree/dir")}>",
		  async: false
		 }).responseText;

		var root=write_root($(".accordionContent"));

		var json_dir=eval("["+json_dir+"]")[0];

		tree_construct(root,json_dir,"<{:U("file/get")}>?file=");//构建树形文件目录

		var as=$(".accordionContent a");
		as.mouseover(function(){
			var curObj=this;
			var path=curObj.rel.replace(/^[\d\D]*=/g,'');
			$("body").data("currentpath",path);
		});
		// console.log(as);

	});

	function result_alert (json_string) {
		var json=eval("["+json_string+"]")[0];
		alert(json["msg"]);
	}
	$(".accordionContent").contextMenu('dirTreeCM', {
	      bindings:{
	            newFile:function(t){
	            	var currentpath=$("body").data("currentpath");
	            	cp=currentpath;
	                currentpath=currentpath.replace(/\/$/,'');
	                currentpath=currentpath.replace(/\/[\d\D][^\/]*$/,'');
	                // console.log(cp);
	                var filename=window.prompt("请输入文件名：");
	                fn=filename;
	                if (filename) {
	                	filename=currentpath+"/"+filename;
		     			// console.log(filename);
		                var result = $.ajax({
		                	type:"POST",
						  url: "<{:U("file/newfile")}>",
						  async: false,
						  data:{'file':filename,'currentpath':cp, 'filename':fn},
						 }).responseText;
		                result_alert(result);
		                window.location.reload();
	                };
	     			
	            },
	            newDir:function(t){
                  	var currentpath=$("body").data("currentpath");
                  	var cp=currentpath;
	                currentpath=currentpath.replace(/\/$/,'');
	                currentpath=currentpath.replace(/\/[\d\D][^\/]*$/,'');
	                var dirname=window.prompt("请输入文件夹名：");
	                if (dirname) {
		                var result = $.ajax({
		                	type:"POST",
						  url: "<{:U("file/newdir")}>",
						  async: false,
						  data:{'currentpath':cp, 'filename':dirname,'parentpath':currentpath},
						 }).responseText;
		                result_alert(result);
		                window.location.reload();
	                };
	            },
	            delete:function(t){
	                var currentpath=$("body").data("currentpath");//当前文件路径
	                if (!window.confirm("确认删除"+currentpath+"？")) {
	                	return 0;
	                };
	                // console.log(currentpath);
	                var result = $.ajax({
	                	type:"POST",
					  url: "<{:U("file/delete")}>",
					  async: false,
					  data:{'file':currentpath},
					 }).responseText;
	                result_alert(result);
	                window.location.reload();
	            },
	            rename:function(t){
	            	var currentpath=$("body").data("currentpath");
	            	var newname=window.prompt("输入新名称：");
	            	if (!newname||newname=="") {
	                	return 0;
	                };
	                var result = $.ajax({
	                	type:"POST",
					  url: "<{:U("file/rename")}>",
					  async: false,
					  data:{'oldpath':currentpath,'newname':newname},
					 }).responseText;
	                result_alert(result);
	            	window.location.reload();
	            }
	      },

	      ctrSub:function(t,m){
	            var mCur = m.find("[rel='newFile']");
	            var mOther = m.find("[rel='newDir']");
	            var mAll = m.find("[rel='delete']");
	            var mRename = m.find("[rel='rename']");
	            // TODO
	      }
	});


</script>